/* CSS Variables for theming */
:root {
    --bg-color: #2c3e50; /* Dark blue-gray */
    --text-color: #ecf0f1; /* Light gray */
    --game-container-bg: #34495e; /* Slightly lighter blue-gray */
    --panel-bg: #2c3e50;
    --highlight-color: #e67e22; /* Orange */
    --highlight-text-color: #f1c40f; /* Yellow */
    --button-hover-bg: #d35400; /* Darker orange */
    --disabled-btn-bg: #95a5a6; /* Grayed out */
    --message-color: #bdc3c7;
    --input-bg: #ecf0f1;
    --input-text-color: #34495e;
    --input-placeholder-color: #95a5a6;
    --modal-bg: #34495e;
    --modal-shadow: rgba(0, 0, 0, 0.5);
    --close-btn-bg: #e74c3c; /* Red */
    --close-btn-hover-bg: #c0392b; /* Darker red */
}

.light-theme {
    --bg-color: #f5f6fa;
    --text-color: #2f3640;
    --game-container-bg: #ffffff;
    --panel-bg: #f5f6fa;
    --highlight-color: #0097e6;
    --highlight-text-color: #273c75;
    --button-hover-bg: #00a8ff;
    --disabled-btn-bg: #dcdde1;
    --message-color: #7f8c8d;
    --input-bg: #f5f6fa;
    --input-text-color: #2f3640;
    --input-placeholder-color: #7f8c8d;
    --modal-bg: #ffffff;
    --modal-shadow: rgba(0, 0, 0, 0.15);
    --close-btn-bg: #e84118;
    --close-btn-hover-bg: #c23616;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    padding: 20px;
    box-sizing: border-box;
    transition: background-color 0.3s ease, color 0.3s ease; /* Smooth transition */
}

.game-container {
    background-color: var(--game-container-bg);
    border-radius: 10px;
    box-shadow: 0 5px 15px var(--modal-shadow);
    padding: 30px;
    width: 100%;
    max-width: 600px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 20px;
    transition: background-color 0.3s ease;
}

h1 {
    color: var(--highlight-color);
    margin-top: 0;
    font-size: 2em;
    transition: color 0.3s ease;
}

.stats-panel, .message-panel, .actions-panel, .input-panel {
    background-color: var(--panel-bg);
    border-radius: 8px;
    padding: 15px;
    text-align: left;
    transition: background-color 0.3s ease;
}

.stats-panel p {
    margin: 5px 0;
    font-size: 1.1em;
}

.stats-panel span {
    color: var(--highlight-text-color);
    font-weight: bold;
    transition: color 0.3s ease;
}

.message-panel {
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-style: italic;
    font-size: 1.1em;
    color: var(--message-color);
    text-align: center;
    transition: color 0.3s ease;
}

.input-panel {
    display: flex;
    flex-direction: column; /* Changed to column to stack prefix input and gender selection */
    gap: 15px; /* Increased gap */
    justify-content: center;
    padding: 15px;
}

#prefix-input {
    flex-grow: 1;
    padding: 10px;
    border: 1px solid #7f8c8d;
    border-radius: 5px;
    background-color: var(--input-bg);
    color: var(--input-text-color);
    font-size: 1em;
    transition: background-color 0.3s ease, color 0.3s ease;
}

#prefix-input::placeholder {
    color: var(--input-placeholder-color);
}

.gender-selection {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px; /* Space between radio buttons and labels */
    font-size: 1.1em;
    color: var(--text-color);
}

.gender-selection p {
    margin: 0;
    font-weight: bold;
}

.gender-selection input[type="radio"] {
    appearance: none; /* Hide default radio button */
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid var(--highlight-color);
    border-radius: 50%;
    outline: none;
    cursor: pointer;
    position: relative;
    top: 2px;
    transition: border-color 0.2s ease;
}

.gender-selection input[type="radio"]:checked {
    background-color: var(--highlight-color);
    border-color: var(--highlight-color);
}

.gender-selection input[type="radio"]:checked::before {
    content: '';
    display: block;
    width: 8px;
    height: 8px;
    background-color: var(--input-bg); /* Inner dot color */
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.gender-selection label {
    cursor: pointer;
    margin-right: 5px;
    transition: color 0.3s ease;
}

.action-btn, #start-game-btn {
    background-color: var(--highlight-color); /* Orange */
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    font-size: 1em;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.action-btn:hover, #start-game-btn:hover {
    background-color: var(--button-hover-bg); /* Darker orange */
    transform: translateY(-2px);
}

.action-btn:active, #start-game-btn:active {
    transform: translateY(0);
}

.action-btn:disabled, #start-game-btn:disabled {
    background-color: var(--disabled-btn-bg); /* Grayed out */
    cursor: not-allowed;
    transform: none;
}

.actions-panel {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    max-height: 250px; /* Added for potential scrolling if too many buttons */
    overflow-y: auto; /* Added for potential scrolling if too many buttons */
    padding-right: 5px; /* Space for scrollbar */
}

/* New styles for cat selection modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: opacity 0.3s ease;
    opacity: 1; /* Default to visible, use 'hidden' class to hide */
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none; /* Disable interactions when hidden */
}

.modal-content {
    background-color: var(--modal-bg);
    border-radius: 10px;
    padding: 30px;
    box-shadow: 0 5px 20px var(--modal-shadow);
    text-align: center;
    max-width: 500px;
    width: 90%;
    transform: translateY(0);
    transition: transform 0.3s ease, opacity 0.3s ease, background-color 0.3s ease;
}

.modal-overlay.hidden .modal-content {
    transform: translateY(-50px);
    opacity: 0;
}

.modal-content h2 {
    color: var(--highlight-text-color);
    margin-top: 0;
    margin-bottom: 20px;
    transition: color 0.3s ease;
}

.button-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-bottom: 20px;
    max-height: 300px; /* Limit height for scrollability */
    overflow-y: auto; /* Enable scrolling for many cats */
    padding-right: 5px; /* Account for scrollbar */
}

/* Style for individual cat buttons within the modal */
.cat-selection-item {
    display: flex;
    gap: 5px;
    width: 100%;
    max-width: 250px;
    align-items: stretch;
}

.select-cat-btn {
    flex: 1;
    padding: 12px 15px;
    font-size: 1em;
}

.info-btn {
    width: 44px;
    padding: 0;
    font-size: 1.2em;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #3498db;
}

.info-btn:hover {
    background-color: #2980b9;
}

/* Close button specific styling */
#close-cat-selection, #close-moon-events {
    background-color: var(--close-btn-bg); /* Red */
}

#close-cat-selection:hover, #close-moon-events:hover {
    background-color: var(--close-btn-hover-bg); /* Darker red */
}

/* Styles for Moon Events Modal - uses same .modal-overlay and .modal-content */
.message-list {
    text-align: left;
    margin-bottom: 20px;
    max-height: 250px;
    overflow-y: auto;
    padding-right: 10px; /* Space for scrollbar */
}

.message-list p {
    margin: 8px 0;
    line-height: 1.4;
    color: var(--text-color);
}

/* Settings Modal Styles */
.settings-btn {
    margin-top: 15px;
    background-color: #7f8c8d;
}

.settings-btn:hover {
    background-color: #95a5a6;
}

.settings-options {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 25px;
    text-align: left;
    padding: 10px;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    padding: 10px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.05);
}

.setting-text {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.setting-item span {
    font-size: 1.1em;
    font-weight: bold;
}

.setting-desc {
    margin: 4px 0 0 0;
    font-size: 0.85em;
    opacity: 0.8;
}

/* Theme Toggle Button */
.theme-toggle {
    background-color: #27ae60; /* Green */
    margin-top: 0;
}

.theme-toggle:hover {
    background-color: #2ecc71; /* Lighter green */
}

.save-load-panel {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 10px;
}

.save-btn {
    background-color: #3498db;
}

.save-btn:hover {
    background-color: #2980b9;
}

.load-btn {
    background-color: #9b59b6;
    display: inline-block;
}

.load-btn:hover {
    background-color: #8e44ad;
}

/* Styles for choice buttons container */
.choice-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
    margin-bottom: 20px; /* Space above/below other panels */
    max-height: 200px; /* Limit height for scrollability */
    overflow-y: auto; /* Enable scrolling for many choices */
    padding-right: 5px; /* Account for scrollbar */
}

.choice-container .choice-btn {
    flex: 1 1 auto; /* Allow buttons to grow/shrink */
    min-width: 150px; /* Minimum width for choice buttons */
}